include ../CommonMakefile       #     $(SCALAC) $(J)

PACKAGEDIR=edu/upenn/seas/peerreview/smui
VARIANTSDIR=edu/upenn/seas/peerreview/smui/variants
OTHERSRC= ../Common.scala ../Debug.scala
SRC= $(OTHERSRC) $(wildcard main/*.scala) $(wildcard stubs/*.scala) $(wildcard main/nonrpc/*.scala) $(wildcard main/rpc/*.scala) $(wildcard main/app-variants/*.scala) $(wildcard main/sm-variants/*.scala)
TESTSRC = $(wildcard tests/*Test.scala)
JARNAME=smui.jar

LIB        = ../lib
SCALACP = $(LIB)/scala-library.jar$(PATHSEP).
CPDEPS = #transport

SCALATEST = scalatest-1.0

LIBJAR = $(LIB)/$(1)/$(1).jar
MAINCP = -classpath $(SCALACP)
TESTCP = $(MAINCP)$(PATHSEP)../transport/transport.jar$(PATHSEP)../pr/pr.jar$(PATHSEP)smui.jar
SCALATESTCP = $(TESTCP)$(PATHSEP)$(call LIBJAR,$(SCALATEST))

all: $(JARNAME)

test: all TEST.out

# Compile the main classes.
.classes: $(SRC) $(CPDEPS)
	$(SCALAC) -deprecation $(MAINCP) $(SRC)
	@touch .classes

# Create the main classes jar.
$(JARNAME): .classes
	jar cf $(JARNAME) $(PACKAGEDIR)
# Compile the tester files.
TEST.classes: $(TESTSRC) $(CPDEPS) $(JARNAME)
	$(SCALAC) -deprecation $(SCALATESTCP) $(TESTSRC)
	@touch TEST.classes

# Run the testers.
TEST.out: TEST.classes
	#Run all tests in current directory.
	scala	$(SCALATESTCP)$(PATHSEP) org.scalatest.tools.Runner -o -p . |\
		tee $@ 2>&1 | grep -v 'at .*[0-9])'

# Run stub test.
stubtest: $(CPDEPS) $(JARNAME)
	scalac $(TESTCP) tests/RGRTester.scala
	java $(TESTCP) RGRTester

clean:
	rm -rf edu $(JARNAME) .classes *.class TEST.out TEST.classes
